<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <button id="btn">发送验证码</button>
    <script>
      
        var btn = document.getElementById("btn");
        btn.onclick = function(){  
             var num = 5;
            var timer = setInterval(function(){
            
            if(num>=0)
            {   
                btn.disabled = true;
                btn.innerHTML = num;
                num--;
            }
            else{
                btn.innerHTML = "发送验证码"
                btn.disabled = false;
                clearTimeout(timer)
                num=5;
            }
        },1000)
        }
    </script>
</body>
</html>